const WX_EXTEND = require('lib/js/$wx_extend.js');
const SERVICE = require('lib/js/service.js');

App({
  onLaunch(){
  
  },

  onShow(){
    let start_params = wx.getLaunchOptionsSync();
    let token = wx.getStorageSync('token');
    
    if (!token && start_params.path.indexOf('authorization') < 0) {
      wx.showModal({
        title: '提示',
        content: '请先登录',
        success(res){
          if(res.confirm){
            wx.redirectTo({
              url: '/pages/tab-bar/authorization/authorization'
            });
          }
        }
      });
    }
  },
  
  //服务
  ajax: SERVICE,

  //微信扩展方法
  $wx: WX_EXTEND,

  //App 全局数据
  globalData: {
    getColor(){
      let color = wx.getStorageSync('shopConfig').color;
     
      return {
        bg: `background-color:${color}`,
        br: `border-color:${color}`,
        color: `color:${color}`,
        val: color
      }
    },
    lazyLoadImg: '/imgs/dp_jz_bg.png'
  },

  //自定义tabbar 配置数据
  tabbarList: [
    {
      pagePath: "pages/tab-bar/shop/shop",
      iconSrc: '/imgs/wm_ico_dp.png',
      selectedIconSrc: '/imgs/wm_ico_dp_1.png',
      text: '店铺'
    },
    {
      pagePath: "pages/tab-bar/order/order",
      iconSrc: '/imgs/wm_ico_dd.png',
      selectedIconSrc: '/imgs/wm_ico_dd_1.png',
      text: '订单'
    },
    {
      pagePath: "pages/tab-bar/my/my",
      iconSrc: '/imgs/wm_ico_wd.png',
      selectedIconSrc: '/imgs/wm_ico_wd_1.png',
      text: '我的'
    }
  ]
});